//
//  MYUIBarButtonItem+Extension.swift
//  MYWeiBo
//
//  Created by apple on 16/5/15.
//  Copyright © 2016年 YanMo. All rights reserved.
//

import UIKit
extension UIBarButtonItem {
    //通过便利构造函数来添加
    convenience init(imageName:String,target: AnyObject?,action: Selector){
        //创建按钮
        let button = UIButton()
        button.setImage(UIImage(named:imageName), forState: UIControlState.Normal)
        button.setImage(UIImage(named:imageName + "_highlighted"),  forState: UIControlState.Highlighted)
        button.sizeToFit()
        //点击事件
        button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        self.init(customView:button)
    }
}
